<?php
// +----------------------------------------------------------------------
// | 海豚PHP框架 [ DolphinPHP ]
// +----------------------------------------------------------------------
// | 版权所有 2016~2019 深圳市中南网络科技有限公司 [ http://www.znwlsz.com ]
// +----------------------------------------------------------------------
// | 官方网站: http://www.znwlsz.com
// +----------------------------------------------------------------------

namespace app\admin\controller;

use app\common\builder\ZBuilder;
use app\common\model\User as U;
use think\Db;
/**
 * 辅食控制器
 * @package app\admin\controller
 */
class User extends Admin
{
 
    public function index()
    {
        $data_list = U::where($this->getMap())
            ->order($this->getOrder('id DESC'))
            ->paginate();
            // jieduan type
        
        $fields = [
            ['hidden', 'id'],
            ['text', 'username', '姓名'],
            ['text', 'phone', '手机号码'],

            ['hidden', 'create_time', time()],
        ];

        return ZBuilder::make('table')
            ->setSearch(['username' => '姓名','phone'=>'手机号码']) // 设置搜索参数
            ->addColumns([
                ['id', 'ID'],
                ['username','姓名'],
                ['phone','手机号码'],
                ['create_time', '创建时间', 'datetime'],
                ['right_button', '操作', 'btn'],
            ])
            ->setTableName('user')
            ->autoAdd($fields, 'user', true, true,'','',true) // 添加新增按钮
            ->autoEdit($fields, 'user', true, true,'','',[],true) // 添加编辑按钮
            ->addRightButton('delete')
            ->addTopButtons('delete')
            ->setRowList($data_list)
            ->fetch();
    }

}